//
//  BaseController.m
//  Postre
//
//  Created by CoderLT on 2017/5/22.
//  Copyright © 2017年 CoderLT. All rights reserved.
//

#import "BaseController.h"

@interface BaseController ()

@end

@implementation BaseController
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    
    if (!self.haveDidAppearFirst) {
        @weakify(self)
        dispatch_async(dispatch_get_main_queue(), ^{
            @strongify(self)
            self.haveDidAppearFirst = YES;
        });
    }
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.viewIsAppear = YES;
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    self.viewIsAppear = NO;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor appBackgroundColor];
}
- (void)dealloc {
    NSLog(@"dealloc %@", self.className);
}

#pragma mark - actions
- (void)showLeftNavTitle:(NSString *)title backItem:(BOOL)show {
    [self showNavTitle:nil backItem:show];
    
    UIButton *item = [UIButton buttonWithType:UIButtonTypeCustom];
    item.userInteractionEnabled = NO;
    item.titleLabel.font = [UIFont appHelveticaBold:16.0f];
    [item setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [item setTitle:title forState:UIControlStateNormal];
    [item sizeToFit];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:item];
    self.at_statisticsTitle = title;
}

#pragma mark - 屏幕旋转实现
ATAutoRotateImplementation
+ (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleDefault;
}
+ (BOOL)prefersStatusBarHidden {
    return NO;
}
+ (UIStatusBarAnimation)preferredStatusBarUpdateAnimation {
    return UIStatusBarAnimationFade;
}
+ (BOOL)shouldAutorotate {
    return YES;
}
+ (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}
+ (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationPortrait;
}
@end
